<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>新高考模拟选课系统</title>
		<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
		<link href="css/edu.css" rel="stylesheet" type="text/css">
		<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<link href="css/font-awesome.css" rel="stylesheet" type="text/css">
		<link href="css/default.css" rel="stylesheet" type="text/css">
		<link href="css/slide-unlock.css" rel="stylesheet" type="text/css">
		
		<script src="js/jquery.js"></script>
		<script src="js/jquery.artDialog.js"></script>
		<script src="js/jquery.slideunlock.js"></script>
		<script type="text/javascript">
		
		//创建异步对象
		/* function createXMLHttpRequest(){
			try {
				return new XMLHttpRequest();//大多数浏览器
			} catch (e) {
				try {
					return ActvieXobject("Msxml2/XMLHTTP");//IE6.0				
					} catch (e) {
					try {
						return ActvieXobject("Microsoft.XMLHTTP");//IE5.5及更早
					} catch (e) {
						alert("什么浏览器?");
						throw e;
					}
				}
			}
		} */
			window.onload=function(){
			
		
			//获取文本框，给它失去焦点事件监听
				var sId=document.getElementById("sid");
				sId.onblur=function(){
			/* 		//1.得到异步对象
					var xmlHttp=createXMLHttpRequest();
					//2.打开链接
					xmlHttp.open("POST","Studentinfocontroller/sId",true);
					//3.设置请求头
					xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
					//4.发送请求，给出请求体
					xmlHttp.send("sid="+sId.value);
					//5.给xmlHttp的onreadystatechange事件注册监听
					xmlHttp.onreadystatechange=function(){
						if(xmlHttp.readyState=4&& xmlHttp.status==200){
							//获取服务器的响应
							var text=xmlHttp.responseText;
							var span=document.getElementById("errorSpan");
							if(text=="1"){
								span.innerHTML="*学号已被注册!";
								$("#errorSpan").css("color","red");
							}else{
								span.innerHTML="";
							}
						}
					}; */
					
					//方法二
			 		var span=document.getElementById("errorSpan");
					if ($("#sid").val()) {
						$.ajax({
							type: "post",
							url: "Studentinfocontroller/sId",
							data: {
								sid: $("#sid").val(),
							},
							success: function(data) {
								if (data=="1") {
									span.innerHTML="*学号已被注册!";
									$("#errorSpan").css("color","red");
								} else {
									span.innerHTML="";
								}
							},
						})
					}
					
					
				};
				
			};
			var myTimer;
			var second=30;
			function sendCode(){
				var btn=document.getElementById("btn");
				btn.setAttribute("disabled","disabled");
				myTimer=setTimeout(sendCode,1000);
				second--;
				btn.value=second+"秒后重发";
				if(second==0){
					clearTimeout(myTimer);
					btn.removeAttribute("disabled");
					second=30;
					btn.value="发送验证码";
				}

			}
	
			
			
		</script>
	</head>
	<body>
		<div class="container-fulid selection-login">
			<div class="row">
				<h3 class="text-center"><i class="fa fa-desktop" style="margin-right:6px;"></i>福建省新高考模拟选课</h3>
				<div class="login-wrap">
					<div class="container">
						<div class="col-md-4 col-md-offset-8">
							<div class="login2-panel panel panel-default">
								<div class="panel-heading">
									<h3 class="panel-title">注册</h3>
								</div>
								<div class="panel-body">
									<form action="Studentinfocontroller/RegistServlet" method="post">
										<div class="input-group ">
											<span class="input-group-addon"><i class="fa fa-user-circle-o fa-fw"></i></span>
											<input class="form-control" type="text" id="name" name="name" placeholder="请输入你的名字" required>
										</div>
										<div class="input-group ">
											<span class="input-group-addon"><i class="fa fa fa-id-card fa-fw"></i></span>
											<input class="form-control" type="text" id="sid" name="sid" placeholder="请输入你的学号" required>
										</div>
										<span id="errorSpan"></span>
										<div class="input-group">
											<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
											<input class="form-control" type="text" id="password" name="password" placeholder="请设置登录密码" required>
										</div>
										<div class="input-group">
											<span class="input-group-addon"><i class="fa fa-envelope fa-fw"></i></span>
											<input class="form-control" type="text" placeholder="请输入你的邮箱账号" id="email" name="email" required>
										</div>
										<div class="input-group">
											<span class="input-group-addon"><i class="fa fa-text-width fa-fw"></i></span>
											<input class="form-control" type="text" placeholder="请输入验证码" id="vcode" name="vcode" required style="width: 175px;"
											 required>
											<img id="img" src="Kaptcha.jpg?r=Math.random()" onclick="refreshImg()">
										</div>
										<div class="input-group">
											<span class="input-group-addon"><i class="fa fa-text-width fa-fw"></i></span>
											<input class="form-control" type="text" placeholder="请输入邮箱验证码" name="code" id="code" style="width: 175px;"
											 required>
											<input type="button" name="btn" class="btn btn-default" id="btn" onclick="sendCode()" value="发送验证码">
										</div>
										<div>
											<input class="btn btn-success" style="width: 316px;" type="submit" id="submit" value="立即注册">
										</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
